package com.jiazhong.basic.shuxin.thread;

import lombok.SneakyThrows;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class DemoD3 {

    private Lock lock = new ReentrantLock();
    @SneakyThrows
    public void d3() {
        String currentThreadName = Thread.currentThread().getName();
        System.out.println(currentThreadName + "开开心心去执行");
        lock.lock();
        System.out.println(currentThreadName + "准备执行代码a");
        Thread.sleep(10000);
        System.out.println(currentThreadName + "结束执行代码a");
        lock.unlock();
    }
}
